function [f,alpha,G] = neural_net(x,h,y,kh)
%
% Artificial Neural Network Basis Function
% by Eduardo Souza-Rodrigues

% Dimension of Y
T = size(y,1);

% Separate mu from sigma
dim   = size(x,1);
mu    = x(1:kh,1);
sigma = x(kh+1:dim,1);

% Basis Function
G = zeros(T,kh);
for j=1:kh
    G(:,j) = normcdf((y-mu(j,1)*ones(T,1))/sigma(j,1));
end

% Alpha
alpha = (G'*G)\(G'*h);

% Least Squares Difference
LS = (h - G*alpha).^2;

% Function
f = sum(LS);

